﻿using System;

namespace Moonlite.Languages.vJass
{
    public static class RegularExpressions
    {
        public static string Library = @"[ \t]*library\s+(?<name>[a-zA-Z0-9]+)(\s+initializer\s+(?<initializer>[a-zA-Z0-9]+))?(\s+(requires|uses|needs)\s+(?<inherits>[\w \t,]+))?";
        public static string Scope = @"[ \t]*scope\s+(?<name>[a-zA-Z0-9]+)(\s+initializer\s+(?<initializer>[a-zA-Z0-9]))?";
        public static string Struct = @"[ \t]*(?<public>public)?\s*(?<private>private)?\s*(?<macrovisibility>\$\w+\$\s+)?struct\s+(?<name>(\w+|\$\w+\$))(\s+extends\s+(?<extends>[a-zA-Z0-9]))?";
        public static string Module = @"[ \t]*module\s+(?<name>[a-zA-Z0-9]+)";
        public static string Interface = @"[ \t]*interface\s+(?<name>[a-zA-Z0-9]+)";

        public static string LibraryEnd = @"[ \t]*endlibrary";
        public static string ScopeEnd = @"[ \t]*endscope";
        public static string StructEnd = @"[ \t]*endstruct";
        public static string ModuleEnd = @"[ \t]*endmodule";
        public static string InterfaceEnd = @"[ \t]*endinterface";

        public static string LibraryZincEnd = @"[ \t]*}";
        public static string ScopeZincEnd = @"[ \t]*}";
        public static string StructZincEnd = @"[ \t]*}";
        public static string ModuleZincEnd = @"[ \t]*}";
        public static string InterfaceZincEnd = @"[ \t]*}";

        public static string Function = @"[ \\t]*(?<public>public)?\s*(?<private>private)?\s*(?<constant>constant)?\s*function\s+(?<name>\w+)\s+takes(?<arguments>[\w \t,]+)\s+returns\s+(?<returns>\w+)";
        public static string Method = @"[ \\t]*(?<public>public)?\s*(?<private>private)?\s*(?<static>static)?\s*(?<constant>constant)?\s*method\s+(?<name>\w+)\s+takes(?<arguments>[\w \t,]+)\s+returns\s+(?<returns>\w+)";

        public static string FunctionZinc = @"[ \t]*(?<public>public)?\s*(?<private>private)?\s*(?<constant>constant)?\s*function\s+(?<name>[a-zA-Z0-9])\s*\((?<arguments>[\w \t,]*\)(\*\-\>\s*(?<returns>[a-zA-Z0-9]))?";
        public static string MethodZinc = @"[ \t]*(?<public>public)?\s*(?<private>private)?\s*(?<static>static)?\s*(?<constant>constant)?\s*method\s+(?<name>[a-zA-Z0-9])\s*\(?<arguments>[\w \t,]*\)(\*\->\s*(?<returns>[a-zA-Z0-9]))?";

        public static string FunctionEnd = @"[ \t]*endfunction";
        public static string MethodEnd = @"[ \t]*endmethod";

        public static string FunctionEndZinc = @"[ \t]*}";
        public static string MethodEndZinc = @"[ \t]*}";

        public static string Globals = @"[ \t]*globals";
        public static string GlobalsEnd = @"[ \t]*endglobals";
        public static string GlobalsEndZinc = @"[ \t]*}";

        public static string Implement = @"[ \t]*implement\s+(optional)?\s+(?<name>[a-zA-Z0-9])";

        public static string VariableGlobal = @"[ \t]*(?<public>public\s+)?(?<private>private\s+)?(?<constant>constant\s+)?(?<type>[a-zA-Z0-9]+)\s+(?<array>array\s+)?(?<name>\w+)(\[)?(\])?(\s*\=\s*(?<value>.+))?";
        public static string VariableLocal = @"[ \t]*local\s+(?<type>[a-zA-Z0-9]+)\s+(?<name>[a-zA-Z0-9]+)(\s*\=\s*(?<value>.+))?";
        public static string VariableStruct = @"[ \t]*(?<public>public\s+)?(?<private>private\s+)?(?<static>static)?\s*(?<constant>constant\s+)?(?<type>[a-zA-Z0-9]+)\s+(?<array>array\s+)?(?<name>\w+)(\[)?(\])?(\s*\=\s*(?<value>.+))?";

        public static string VariableGlobalZinc = VariableGlobal;
        public static string VariableLocalZinc = @"[ \t]*(?<type>[a-zA-Z0-9]+)\s+(?<name>[a-zA-Z0-9]+)(\s*\=\s*(?<value>.+))?;";
        public static string VariableStructZinc = VariableStruct;
    }
}
